<template>
<view :class="[config.style]">
		<!--数据列表部分-->
		<view class="list-section uni-clearfix">
			<!-- top="xxx"下拉布局往下偏移,防止被悬浮菜单遮住 -->
			<mescroll-uni ref="mescrollRef" @init="mescrollInit" top="0" :down="downOption" @down="downCallback" @up="upCallback">
				<!-- 数据列表 -->
				<view class="list">
					<view class="item" v-for="(item,index) in list" :key="index" v-if="item.user_info.nickname">
						<view class="avatar-info">
							<image class="image" :src="item.user_info.avatar"></image>
							{{item.user_info.nickname}}
						</view>
						<view class="nickname-info text-ellipsis">
							{{item.user_info.nickname}}
						</view>
						<view class="leval-info">
							<text>{{item.leval}}</text>
							<text>级</text>
						</view>
					</view>
				</view>
			</mescroll-uni>
		</view>
	</view>
</template>

<script>
	import { mapState,mapMutations } from 'vuex'
	
	export default {
		components: {

		},
		data() {
			return {
				page: 1, //当前页码
				list: [], // 订单列表
				downOption: {
					auto: false //是否在初始化后,自动执行downCallback; 默认true
				},
				upOption:{
					// page: {
					// 	size: 10 // 每页数据的数量
					// },
					noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty:{
						tip: '~ 搜索无数据 ~', // 提示
						btnText: '去看看'
					}
				},
			}
		},
		created() {

		},
		computed: {
			...mapState(['config'])
		},
		methods: {

			//上拉加载的回调
			upCallback: function() {
				let that = this
				let data = {}
					data.action = 'subordinate'
					data.page = this.page
				let url = ''
					//#ifdef MP-WEIXIN
					url = 'entry/wxapp/distribution'
					//#endif
					//#ifdef H5
					url = 'entry/site/distribution'
					//#endif
				//获取数据
				this.util.request({
					url : url,
					data : data,
					success: function (res) {
						if (res.data.code == 200) {
							let list = res.data.data.data
							that.list = that.list.concat(list);
							//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
							that.mescroll.endSuccess(list.length);
							that.page = that.page + 1
						}
					}
				})
			},
			//下拉刷新
			downCallback: function() {
				let that = this
				this.page = 1
				let data = {}
					data.action = 'subordinate'
					data.page = this.page
				let url = ''
					//#ifdef MP-WEIXIN
					url = 'entry/wxapp/distribution'
					//#endif
					//#ifdef H5
					url = 'entry/site/distribution'
					//#endif
				//获取数据
				this.util.request({
					url : url,
					data : data,
					success: function (res) {
						if (res.data.code == 200) {
							that.list = []
							that.list = res.data.data.data
							//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
							that.mescroll.endSuccess(that.list.length);
							that.page = 2
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #f8f8f8;
		min-height: 100%;
		height: auto;
	}
	
	.list {
		
		.item {
			display: flex;
			padding: 20rpx;
			background-color: #fff;
			margin: 10rpx auto;
			.avatar-info {
				position: relative;
				width: 64rpx;
				height: 64rpx;
				border-radius: 50%;
				overflow: hidden;
				z-index: 2;
				image {
					width: 64rpx;
					height: 64rpx;
					display: block;
					z-index: 1;
				}
			}
			.nickname-info {
				font-size: 28rpx;
				line-height: 64rpx;
				width: 500rpx;
				padding-left: 20rpx;
			}
			.leval-info {
				flex: 1;
				font-size: 26rpx;
				color: #666;
				text-align: center;
				line-height: 64rpx;
			}
		}
	}
</style>
